package cn.felord.security.autoconfigure.jackson2;


import cn.felord.security.autoconfigure.authentication.captcha.CaptchaAuthenticationToken;
import cn.felord.security.autoconfigure.authentication.miniapp.douyin.DouyinMiniAppAuthenticationToken;
import cn.felord.security.autoconfigure.authentication.miniapp.wechat.WechatMiniAppAuthenticationToken;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.module.SimpleModule;
import org.springframework.security.jackson2.SecurityJackson2Modules;

/**
 * @author felord.cn
 * @since 1.0.0
 */
public class SecurityJackson2Module extends SimpleModule {

    private static final long serialVersionUID = 3137282573480717744L;

    public SecurityJackson2Module() {
        super(SecurityJackson2Module.class.getName(), new Version(1, 0, 0, null, null, null));
    }

    @Override
    public void setupModule(SetupContext context) {
        SecurityJackson2Modules.enableDefaultTyping(context.getOwner());
        context.setMixInAnnotations(CaptchaAuthenticationToken.class, CaptchaAuthenticationTokenMixin.class);
        context.setMixInAnnotations(WechatMiniAppAuthenticationToken.class, WechatMiniAppAuthenticationTokenMixin.class);
        context.setMixInAnnotations(DouyinMiniAppAuthenticationToken.class, DouyinMiniAppAuthenticationTokenMixin.class);
    }
}
